@echo off
echo Building MarkLocalize...

REM Check if Python is available
python --version >nul 2>&1
if errorlevel 1 (
    echo Python is not installed or not in PATH
    pause
    exit /b 1
)

REM Install dependencies
echo Installing dependencies...
pip install -r requirements.txt
pip install pyinstaller

REM Clean previous builds
if exist "build" rmdir /s /q "build"
if exist "dist" rmdir /s /q "dist"

REM Build the executable
echo Building executable...
pyinstaller build.spec

REM Check if build was successful
if exist "dist\MarkLocalize.exe" (
    echo Build successful!
    echo Executable created at: dist\MarkLocalize.exe
) else (
    echo Build failed!
    pause
    exit /b 1
)

REM Create release package
echo Creating release package...
if exist "release" rmdir /s /q "release"
mkdir release
copy "dist\MarkLocalize.exe" "release\"
copy "README.md" "release\"
copy "LICENSE" "release\"
copy "CHANGELOG.md" "release\"
copy "config.json" "release\"
copy "examples\sample.md" "release\"

echo Release package created in 'release' folder
echo.
echo Build complete!
pause